package io.test;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class ReadJava {
    public static void main(String[] args) throws IOException {
        File dir = new File("src/io");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(f -> f.getName().endsWith(".java"));
            for (int i = 0; i < subs.length; i++) {
                File f = subs[i];
                FileInputStream fis = new FileInputStream(f);
                InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
                BufferedReader br = new BufferedReader(isr);
                String line;
                while ((line = br.readLine())!=null){
                    System.out.println(line);
                }
                System.out.println(f.getName()+"文件输出完毕");
            }
        }else {
            System.out.println("文件不是目录");
        }


    }
}
